+2005-09-18 Øyvind Kolås <pippin@gimp.org>
+
+ * babl/Makefile.am:
+ * babl/babl-classes.h:
+ * babl/babl-conversion.c: (each_babl_conversion_destroy),
+ (conversion_new), (create_name), (babl_conversion_new),
+ (babl_conversion_process), (test_create), (babl_conversion_error):
+ * babl/babl-core.c: (rgba_to_rgba), (babl_core_init):
+ * babl/babl-db.c: (babl_db_count):
+ * babl/babl-db.h:
+ * babl/babl-extension.c:
+ * babl/babl-fish.c: (match_conversion), (babl_conversion_find),
+ (babl_fish_db), (babl_fish), (babl_fish_process),
+ (each_babl_fish_destroy):
+ * babl/babl-format.c: (babl_format_new), (babl_formats_count),
+ (babl_format_with_model_as_type), (test_create),
+ (babl_format_loss):
+ * babl/babl-internal.c: (babl_process), (each_conversion),
+ (each_format), (gen_type_format_for_model),
+ (gen_formats_for_model), (babl_extension_post_load):
+ * babl/babl-internal.h:
+ * babl/babl-introspect.c: (conversion_introspect):
+ * babl/babl-model.c: (babl_model_new), (test_create),
+ (reference_format), (construct_double_format),
+ (babl_model_is_symmetric):
+ * babl/babl-sanity.c: (id_sanity):
+ * babl/babl-type.c: (babl_type_new), (r_interval), (test_init),
+ (double_vector_format), (babl_type_is_symmetric):
+ * babl/babl-util.c: (babl_list_each), (init_ticks), (babl_ticks):
+ * babl/babl-util.h:
+ * babl/base/model-cmyk.c: (rgb_to_cmyk), (cmyk_to_rgb),
+ (conversions), (formats):
+ * babl/base/model-gray.c: (rgba_to_graya), (rgba_to_gray),
+ (graya_to_rgba), (gray_to_rgba), (conversions):
+ * babl/base/model-rgb.c: (formats):
+ * babl/base/model-ycbcr.c: (rgba_to_ycbcra), (rgba_to_ycbcr),
+ (ycbcra_to_rgba), (ycbcr_to_rgba), (conversions), (formats):
+ * docs/Makefile.am:
+ * docs/index-static.html.in:
+ * extensions/CIE-Lab.c: (rgba_to_lab), (lab_to_rgba),
+ (rgba_to_laba), (laba_to_rgba), (conversions):
+ * extensions/Makefile.in:
+ * extensions/naive-CMYK.c: (init), (rgba_to_cmyk), (cmyk_to_rgba):
+ * tests/Makefile.am:
+ * tests/babl-html-dump.c: (main):
+ * tests/conversions.c: (each_conversion), (main):
+ * tests/formats.c: (format_check), (main):
+ * tests/models.c: (model_check), (main):
+ * tests/types.c: (type_check), (main):
+
2005-09-18 Øyvind Kolås <pippin@gimp.org>
* babl/babl.c: (babl_init),
int dst_pitch[],
long n);
-#if 0
-typedef long (*BablFuncPlanarBit) (int src_bands,
- void *src[],
- int src_bit[],
- int src_pitch[],
- int src_bit_pitch[],
- int dst_bands,
- void *dst[],
- int dst_bit[],
- int dst_pitch[],
- int dst_bit_pitch[],
- long n);
-#endif
-
/* magic number used at the start of all babl objects, used to do
* differentiation in polymorphic functions. (as well as manual
* type check assertions).
BABL_FISH,
BABL_FISH_REFERENCE,
BABL_FISH_SIMPLE,
+ BABL_FISH_PATH,
BABL_IMAGE,
BABL_EXTENSION,
BablInstance instance;
union Babl *source;
union Babl *destination;
- int time_cost;
+ int cost;
double error;
union
{
int *stride;
} BablImage;
+/* BablFish base class, the user of babl is just requesting a
+ * conversion, after that an appropriate species of fish is
+ * constructed to handle the request.
+ *
+ * TODO:
+ * * implement
+ */
typedef struct
{
BablInstance instance;
long pixels;
} BablFish;
+
+
+/* BablFishSimple is the simplest type of fish, wrapping a single
+ * conversion function, (note this might not be the optimal chosen
+ * conversion even if it exists)
+ */
+typedef struct
+{
+ BablFish fish;
+ BablConversion *conversion;
+} BablFishSimple;
+
+
+
+/* BablFishPath is a combination of registered conversions, both
+ * from the reference types / model conversions, and optimized paths.
+ *
+ * This is the most advanced scheduled species of fish, some future
+ * version of babl might even be evovling combined fishes in a background
+ * thread, based on profiled usage. For this to work in a future version
+ * transmogrification between the fish classes would be used.
+ */
+typedef struct
+{
+ BablFish fish;
+ double cost;
+ double loss;
+ BablConversion *conversion[BABL_MAX_PATH_LENGTH];
+ int conversions;
+} BablFishPath;
+
/* BablFishReference on the double versions of conversions
* that are required to exist for maximum sanity.
*
* implementation is meant to be kept as small as possible wrt logic.
*
* One of the contributions that would be welcome are new fish factories.
+ *
+ * TODO:
+ * * cache the looked up conversions, removing all overhead but the
+ * actual conversions.
+ * * make optimal use of a single allocation containing enough space
+ * for the maximum amount of memory needed in to adjecant buffers
+ * at any time.
*/
typedef struct
{
BablFish fish;
} BablFishReference;
-/* BablFishSimple is the simplest type of fish, wrapping a single
- * conversion function
- */
-typedef struct
-{
- BablFish fish;
- BablConversion *conversion;
-} BablFishSimple;
-
typedef struct
{
BablInstance instance; /* path to .so / .dll is stored in instance name */
BablConversion conversion;
BablImage image;
BablFish fish;
- BablFishReference reference_fish;
+ BablFishReference fish_reference;
BablFishSimple fish_simple;
+ BablFishPath fish_path;
BablExtension extension;
} Babl;
(*list)[orig_len+1]=NULL;
}
+void
+babl_list_each (void **list,
+ BablEachFunction each_fun,
+ void *user_data)
+{
+ int i;
+ if (!list)
+ return;
+ for (i=0; i < list_length (list); i++)
+ {
+ if (each_fun ((Babl*) list[i], user_data))
+ break;
+ }
+}
+
+#include <sys/time.h>
+#include <time.h>
+
+static struct timeval start_time;
+static struct timeval measure_time;
+
+#define msecs(time) ((time.tv_sec-start_time.tv_sec)*1000 + time.tv_usec/1000)
+
+static void
+init_ticks (void)
+{
+ static int done=0;
+ if (done)
+ return;
+ done=1;
+ gettimeofday (&start_time, NULL);
+}
+
+unsigned int
+babl_ticks (void)
+{
+ init_ticks ();
+ gettimeofday (&measure_time, NULL);
+ return msecs(measure_time) - msecs(start_time);
+}